#include "Stdafx.h"
#include "DirectInput8.h"

using namespace Vortex::Wrapper::DInput;

DirectInputKeyboard8::DirectInputKeyboard8(IDirectInputDevice8W* handle) : DirectInputDevice8(handle){
	// set the data format to keyboard format
	handle->SetDataFormat(&c_dfDIKeyboard);
}

///<summary>Read keyboard states for all of 256 key codes</summary>
HResult DirectInputKeyboard8::ReadStates(array<Byte>^ stateArray) {
	if (!stateArray) throw gcnew ArgumentNullException("stateArray");
	if (stateArray->Length != KEY_COUNT) throw gcnew ArgumentException("Size of keyboard state array should be equal to " + KEY_COUNT, "stateArray");

	pin_ptr<Byte> bytePtr = &stateArray[0];

	return HResult(NativeHandle->GetDeviceState(KEY_COUNT, bytePtr));

}